﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/25/2009
 * Time: 9:50 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Miming.Model;

namespace Miming.Gui
{
	/// <summary>
	/// Description of ChangePasswordForm.
	/// </summary>
	public partial class ChangePasswordForm : BaseForm
	{
		public ChangePasswordForm(User u)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = u;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			User u = Model as User;
			textBoxName.Text = u.Name;
			comboBoxChallengeQuestion.SelectedIndex = u.ChallengeQuestion;
			textBoxAnswer.Text = u.Answer;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			User u = Model as User;
			u.ChallengeQuestion = comboBoxChallengeQuestion.SelectedIndex;
			u.Answer = textBoxAnswer.Text;
			SessionFacade.SaveOrUpdateUser(u);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
